`
Environmental Setup
Before you begin learning bash, you need both a bash shell
running in a terminal and a text editor. You can access these on any
major operating system by following the instructions in this section.
N O T E
Beginning in Chapter 4, you’ll run bash commands and complete hack-
ing labs using Kali Linux. If you’d like to set up Kali now, consult the
steps included in Chapter 3.
Accessing the Bash Shell
If you’re running Linux or macOS, bash should already be
available. On Linux, open the Terminal application by entering
ALT+CTRL+T. On macOS, you can find the terminal by navigating
to the Launchpad icon on the system dock.
Kali and macOS use the Z Shell by default, so when you open a
new terminal window, you’ll have to enter exec bash to switch to
a bash shell before you run commands. If you want to change your
default shell to bash so you don’t have to manually switch shells,
you can use the command chsh -s /bin/bash.
If you’re running Windows, you can make use of the Windows
Subsystem for Linux (WSL), which lets you run Linux distributions
directly on Windows, providing access to a bash environment
without a virtual machine. The official Microsoft WSL
documentation page describes how to install it:
https://learn.microsoft.com/en-us/windows/wsl/install.
An alternative to WSL is Cygwin, which emulates a Linux
environment by providing a collection of Linux utilities and system-
call functionalities. To install Cygwin, visit
https://www.cygwin.com/install.html and download the setup file,
then follow the installation wizard.
Cygwin installs itself by default to the C:/cygwin64/ Windows
path. To execute your bash scripts, save the scripts in the directory
containing your username at C:/cygwin64/home. For example, if
your username is david, you should save your scripts under
C:/cygwin64/home/david. Then, from the Cygwin terminal, you’ll be
able to change the directory to the home directory to run your scripts.
Black Hat Bash (Early Access) © 2023 by Dolev Farhi and Nick Aleks